package com.xiaoxi.strategymode.play;

import com.xiaoxi.strategymode.strategy.IStrategy;

/**
 * @Author xiaoxi
 * @ProjectName design_mode
 * @PackageName com.xiaoxi.strategymode.play
 * @ClassName Player
 * @Description TODO
 * @Date 2023/3/13 20:56
 * @Version 1.0
 */
public class Player {

    private String name;
    private IStrategy iStrategy;

    private int winCount;
    private int loseCount;
    private int gameCount;

    public Player(String name, IStrategy iStrategy) {   // 赋予名字和策略
        this.name = name;
        this.iStrategy = iStrategy;
    }

    public Hand nextHand() {
        return iStrategy.nextHand();
    }

    public void win() {
        iStrategy.study(true);
        winCount++;
    }

    public void lose() {
        iStrategy.study(false);
        loseCount++;
    }

    public void even() {
        gameCount++;
    }

    @Override
    public String toString() {
        return "Player{" +
                "name='" + name + '\'' +
                ", winCount=" + winCount +
                ", loseCount=" + loseCount +
                ", gameCount=" + gameCount +
                '}';
    }
}
